<?php
	session_start();	
?>

<?php
	if( $_SESSION["admin"] != "" )
	{
?>
<script type="text/javascript" language="javascript">
function validateForm()
{
  var valid="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var formObj;
  formObj = document.addcountry;
  if (formObj.country_code.value == "") {
    alert("You have not filled in partner code.");
    formObj.CouponCode.focus();
    return false;
  }
    if (formObj.country_name.value == "") {
    alert("You have not filled in partner name.");
    formObj.CouponTitle.focus();
    return false;
  }
  }
    
return true;
}
</script>
<a href="index.php?com=partner"><b>List partner</a></b> | <b><a href="index.php?com=partner&func=add">Add new partner</b></a>
<br />
<?php 
	include_once("process/partner.php");
	$partner = new partner();
    if( isset($_POST['btnAdd']) )
	{		
			$Title = stripcslashes($_POST["Title"]);
    		$SourceCode=stripcslashes($_POST["SourceCode"]);
    		$Description=stripcslashes($_POST["Description"]);
            $HitNumber=stripcslashes($_POST["HitNumber"]);
            $AddToCart=stripcslashes($_POST["AddToCart"]);
            $Ordered=stripcslashes($_POST["Ordered"]);
            
            $ActiveYN=stripcslashes($_POST["ActiveYN"]);
        //echo $code, $name, $order;
        if($Title != "")
        {
    		$partner->AddPartner($Title, $SourceCode, $Description, $HitNumber, $AddToCart,
             $Ordered, $DateSubmit, $ActiveYN);	
    	//	echo '<meta http-equiv="Refresh" content="0;URL=index.php?com=partner" />';
    		//return;
        }
	}
?>

<form method="post" action="index.php?com=partner&func=add" id="contactform" name="addcountry" onSubmit="return validateForm()">
	<table width="70%" style="font-size:10pt;">
		<tr>
			<td align="center" colspan="2" height="50"><b style="font-size:12pt; color:Blue;">Add new partner</b></td>
		</tr>
		<tr style="font-weight:bold;">
			<td align="right">Title :&nbsp;&nbsp;</td>
			<td>
				<input type="text" class="validate[required]" name="Title" id="Title" /><font style="color: red;"> *</font>
			</td>
		</tr>
        <tr style="font-weight:bold;">
			<td align="right">Source Code :&nbsp;&nbsp;</td>
			<td>
				<input type="text" name="SourceCode" id="SourceCode" /><font style="color: red;"> *</font>
			</td>
		</tr>
        	<tr style="font-weight:bold;">
			<td align="right">Description :&nbsp;&nbsp;</td>
			<td>
				<td><textarea rows="7" name="Description" id="Description" cols="95"></textarea></td>" style="width: 120px;" /><font style="color: red;"> *</font></td>
			</td>
		</tr>
        <tr style="font-weight:bold;">
			<td align="right">Hit Number :&nbsp;&nbsp;</td>
			<td>
				<input type="text" name="HitNumber" id="HitNumber" /><font style="color: red;"> *</font>
			</td>
		</tr>
         <tr style="font-weight:bold;">
			<td align="right">Add To Cart :&nbsp;&nbsp;</td>
			<td>
				<input type="text" name="AddToCart" id="AddToCart" />
			</td>
		</tr>
        <tr style="font-weight:bold;">
			<td align="right">Ordered :&nbsp;&nbsp;</td>
			<td>
				<input type="text" name="Ordered" id="Ordered" />
			</td>
		</tr>
        <tr style="font-weight:bold;">
			<td align="right">ActiveYN :&nbsp;&nbsp;</td>
			<td>
				<select size="1" name="ActiveYN">
        			<option value="No">No</option>
                    <option value="Yes">Yes</option>
			 </select>
			</td>
		</tr>
		<tr>
			<td></td>
			<td colspan="2" align="left" height="40">
				<input type="submit" name="btnAdd" id="btnAdd" value="Add"  />
				<input type="reset" value="Reset" />
			</td>
		</tr>
	</table>
</form>
<i>Please fill in these fields (<font style="color: red;">*</font>)</i>
<?php
    }
   else
	{
		echo "<meta http-equiv='refresh' content='0; url=login.php' />";
	}
?>